{extend name="platform/base" /}
{block name="main"}
<div class="m-b-md">
    <h3 class="m-b-none">第三方SDK参数设置</h3>
</div>
<section class="panel panel-default">
    <div class="panel-body">
        <form class="form-horizontal">
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">上級菜单</label>
                <div class="col-sm-4">
                    <select id="moudelID" name="moudelID" class="form-control m-b">
                        <option value="0">顶级菜单</option>
                        {foreach name="moudelList" item="v1"}
                        <option value="{$v1['moudelID']}" {if condition="$moudelID eq $v1['moudelID']"}selected{/if}>——{$v1['moudeName']}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <input type="hidden" id="paramID" value="{$paramList['paramID']}">
            <div class="m-b-md">
                <h3 class="m-b-none">参数</h3>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">参数键</label>
                <div class="col-sm-4">
                    <input name="param" id="param" class="form-control" type="text" value="{$paramList['param']}">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">参数键值</label>
                <div class="col-sm-4">
                    <input name="paramValue" id="paramValue" class="form-control" type="text" value="{$paramList['paramValue']}">
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <label class="col-sm-2 control-label">是否可用</label>
                <div class="col-sm-4">
                    <label class="switch">
                    <input name="isEnable" id="isEnable" type="checkbox" {if condition="$paramList['isEnable'] eq 1" }checked="checked" {/if}>
                    <span></span>
                    </label>
                </div>
            </div>
            <div class="line line-dashed line-lg pull-in"></div>
            <div class="form-group">
                <div class="col-sm-4 col-sm-offset-2">
                    <input type="hidden" id="module_id" value="{$module_info.module_id}" />
                    <a href="javascript:void(0);" onclick="editmoudelAjax()" class="btn btn-primary">保存</a>
                </div>
            </div>
        </form>
    </div>
</section>
</div>
<script src="__STATIC__/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="__STATIC__/js/file_upload.js" type="text/javascript"></script>
<script>

    function editmoudelAjax() {
        var moudelID = $("#moudelID").val();
        var param = $("#param").val();
        var paramValue = $("#paramValue").val();
        var isEnable = $("#isEnable").val();
        var paramID = $("#paramID").val();

        if ($("#isEnable").prop("checked")) {
            var isEnable = 1;
        } else {
            var isEnable = 0;
        }
        $.ajax({
            type : "post",
            url : "{:__URL('PLATFORM_MAIN/System/editParam')}",
            data : {
                'moudelID' : moudelID,
                'param' : param,
                'paramValue' : paramValue,
                'isEnable' : isEnable,
                'paramID' : paramID,
            },
            async : true,
            success : function(res) {
                if (res["code"] > 0) {
                    showMessage('success', res['message'], "{:__URL('PLATFORM_MAIN/system/setSdkConfigure')}");
                } else {
                    showMessage("error",res['message']);
                }
            }
        });
    }

    /**
     *模块输入信息验证
     */
    function verify(module_name, controller, method, url, sort, desc) {
        if (module_name == '') {
            $("#module_name").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
        if (controller == '') {
            $("#controller").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
        if (method == '') {
            $("#method").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
        if (url == '') {
            $("#url").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
        if (sort == '') {
            $("#sort").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
        if (desc == '') {
            $("#desc").parent().next().show();
            return false;
        } else {
            $(".error").hide();
        }
    }
</script>
{/block}
